///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
#ifndef __ABSTRACT_MANAGER_H__
#define __ABSTRACT_MANAGER_H__
//-----------------------------------------------------------------------------

#include <Config.h>

//-----------------------------------------------------------------------------

template <class T>
class AbstractManager
{
protected:
	AbstractManager(){};
	virtual ~AbstractManager(){};
	
	static	T*	ManageInstance(bool create = true, bool release = false)
	{
		static	T*	m_instance = NULL;
		if( create && !m_instance )
		{
			m_instance = MGL_NEW T();
		}
		if( release && m_instance )
		{
			SAFE_DEL( m_instance );
		}
		return m_instance;
	}

public:

	static	T*	GetInstance()
	{
		return ManageInstance();
	}


	static	bool	HasInstance()
	{
		return ManageInstance( false ) != NULL;
	}


	static	void	ReleaseInstance()
	{
		ManageInstance( false, true );
	}

};

#endif //__ABSTRACT_MANAGER_H__
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
